/*
	File:		BaseGun.h
	Author:		Ben Feldmann
	Purpose:	Class for managing base ranged weapon
*/

#include "BaseGun.h"
#include "MessageSystem.h"
#include "CreateProjectileMessage.h"
#include "GamePlayState.h"
#include "ObjectManager.h"
//#include "Player.h"

#include "SGD Wrappers/CSGD_TextureManager.h"


BaseGun::BaseGun(Player* owner)
{
	SetWidth(32);
	SetHeight(32);
	SetTextureID(CSGD_TextureManager::GetInstance()->LoadTexture(_T("Graphics/Dummy Images/baseGun.png")));

	player = owner;
	SetX(owner->GetX() + owner->GetWidth());
	SetY(owner->GetY());

	ObjectManager::GetInstance()->AddObject(this);
}

BaseGun::~BaseGun()
{
	if(GetTextureID() != -1 )
	{
		CSGD_TextureManager::GetInstance()->UnloadTexture(GetTextureID());
		SetTextureID(-1);
	}
}

bool BaseGun::CheckCollision(IEntity* base) 
{
	return false;
}

void BaseGun::Attack() 
{
	CreateProjectileMessage* msg = new CreateProjectileMessage(BASIC, this);
	MessageSystem::GetInstance()->SendMsg(msg);
	msg = nullptr;
}

void BaseGun::SpecialAttack() 
{

}

void BaseGun::Render()
{
	SetX(player->GetX() + player->GetWidth());
	SetY(player->GetY());

	if(player->GetCurWeapon() == 2)
	{
		if(GetTextureID() != -1)
		{
			CSGD_TextureManager::GetInstance()->Draw(GetTextureID(), int(GetX()), int(GetY()));
		}
	}
}
